package org.jivesoftware.smackx.packet;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.provider.IQProvider;
import org.xmlpull.v1.XmlPullParser;

public class SharedGroupsInfo extends IQ
{
  private List groups = new ArrayList();

  public String getChildElementXML()
  {
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append("<sharedgroup xmlns=\"http://www.jivesoftware.org/protocol/sharedgroup\">");
    Iterator localIterator = this.groups.iterator();
    while (true)
    {
      if (!(localIterator.hasNext()))
      {
        localStringBuilder.append("</sharedgroup>");
        return localStringBuilder.toString();
      }
      localStringBuilder.append("<group>").append(localIterator.next()).append("</group>");
    }
  }

  public List getGroups()
  {
    return this.groups;
  }

  public static class Provider
  implements IQProvider
  {
    public IQ parseIQ(XmlPullParser paramXmlPullParser)
      throws Exception
    {
      SharedGroupsInfo localSharedGroupsInfo = new SharedGroupsInfo();
      int i = 0;
      while (true)
      {
        int j;
        do
          while (true)
          {
            if (i != 0)
              return localSharedGroupsInfo;
            j = paramXmlPullParser.next();
            if ((j != 2) || (!(paramXmlPullParser.getName().equals("group"))))
              break;
            localSharedGroupsInfo.getGroups().add(paramXmlPullParser.nextText());
          }
        while ((j != 3) || (!(paramXmlPullParser.getName().equals("sharedgroup"))));
        i = 1;
      }
    }
  }
}